/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mortbay.jetty.pico.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Hnmtuan
 */
@Entity
@Table(name = "orderdetail")
@NamedQueries({
    @NamedQuery(name = "Orderdetail.findAll", query = "SELECT o FROM Orderdetail o"),
    @NamedQuery(name = "Orderdetail.findByState", query = "SELECT o FROM Orderdetail o WHERE o.state = :state"),
    @NamedQuery(name = "Orderdetail.findByNums", query = "SELECT o FROM Orderdetail o WHERE o.nums = :nums"),
    @NamedQuery(name = "Orderdetail.findByTotalPrices", query = "SELECT o FROM Orderdetail o WHERE o.totalPrices = :totalPrices"),
    @NamedQuery(name = "Orderdetail.findByOrder", query = "SELECT o FROM Orderdetail o WHERE o.orderdetailPK.order = :order"),
    @NamedQuery(name = "Orderdetail.findByItemCode", query = "SELECT o FROM Orderdetail o WHERE o.orderdetailPK.itemCode = :itemCode"),
    @NamedQuery(name = "Orderdetail.findByCateCode", query = "SELECT o FROM Orderdetail o WHERE o.orderdetailPK.cateCode = :cateCode")})
public class Orderdetail implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrderdetailPK orderdetailPK;
    @Column(name = "State")
    private Integer state;
    @Column(name = "Nums")
    private Integer nums;
    @Column(name = "TotalPrices")
    private Float totalPrices;
    @JoinColumns({
        @JoinColumn(name = "ItemCode", referencedColumnName = "IdItem", insertable = false, updatable = false),
        @JoinColumn(name = "CateCode", referencedColumnName = "Category", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Item item;
    @JoinColumn(name = "Order", referencedColumnName = "idOrder", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Order1 order1;

    public Orderdetail() {
    }

    public Orderdetail(OrderdetailPK orderdetailPK) {
        this.orderdetailPK = orderdetailPK;
    }

    public Orderdetail(String order, String itemCode, String cateCode) {
        this.orderdetailPK = new OrderdetailPK(order, itemCode, cateCode);
    }

    public OrderdetailPK getOrderdetailPK() {
        return orderdetailPK;
    }

    public void setOrderdetailPK(OrderdetailPK orderdetailPK) {
        this.orderdetailPK = orderdetailPK;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Integer getNums() {
        return nums;
    }

    public void setNums(Integer nums) {
        this.nums = nums;
    }

    public Float getTotalPrices() {
        return totalPrices;
    }

    public void setTotalPrices(Float totalPrices) {
        this.totalPrices = totalPrices;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public Order1 getOrder1() {
        return order1;
    }

    public void setOrder1(Order1 order1) {
        this.order1 = order1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orderdetailPK != null ? orderdetailPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orderdetail)) {
            return false;
        }
        Orderdetail other = (Orderdetail) object;
        if ((this.orderdetailPK == null && other.orderdetailPK != null) || (this.orderdetailPK != null && !this.orderdetailPK.equals(other.orderdetailPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.mortbay.jetty.pico.entities.Orderdetail[orderdetailPK=" + orderdetailPK + "]";
    }

}
